function timestampToYmd(timestamp) {
  const date = new Date(timestamp);
  const year = date.getFullYear();
  // 月份从0开始，需+1，且不足2位补0
  const month = String(date.getMonth() + 1).padStart(2, '0');
  // 日期不足2位补0
  const day = String(date.getDate()).padStart(2, '0');
  return year + month + day;
}

function timestampToYmdhm(timestamp) {
  const date = new Date(timestamp);
  
  // 获取各时间部分并补零
  const year = date.getFullYear();
  const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始
  const day = String(date.getDate()).padStart(2, '0');
  const hours = String(date.getHours()).padStart(2, '0'); // 24小时制
  const minutes = String(date.getMinutes()).padStart(2, '0');
  
  // 拼接为目标格式
  return `${year}${month}${day}-${hours}:${minutes}`;
}
function timestampToDateTime(timestamp) {
  const date = new Date(timestamp);
  
  // 获取各时间部分并确保两位数字格式
  const year = date.getFullYear();
  const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始计数
  const day = String(date.getDate()).padStart(2, '0');
  const hours = String(date.getHours()).padStart(2, '0');
  const minutes = String(date.getMinutes()).padStart(2, '0');
  const seconds = String(date.getSeconds()).padStart(2, '0');
  
  // 拼接成目标格式
  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}


export {
  timestampToYmd,
  timestampToYmdhm,
  timestampToDateTime,

}   

